set scheme s2color

use "$project_path/data/4_regdata/regdata", clear

** Figure 4(a)
use "$project_path/data/4_regdata/regdata", clear
rdrobust diff_m1_chix_econ runvar, all
local rdd_tau : di %8.3f e(tau_cl)
local rdd_lb : di %8.3f e(ci_l_rb)
local rdd_lb = subinstr("`rdd_lb'", " ", "", .)
local rdd_ub : di %8.3f e(ci_r_rb)
local rdd_ub = subinstr("`rdd_ub'", " ", "", .)
local rdd_pval : di %8.3f e(pv_rb)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local N = e(N)
local rd_est = "RD est.: `rdd_tau' [`rdd_lb', `rdd_ub']. p-value: `rdd_pval'. N = `N'"
rdplot diff_m1_chix_econ runvar if inrange(runvar, -20, 20), nbins(10 10)  p(1) graph_options(xtitle("Margin of victory of the challenger", size(large)) graphregion(color(white)) note("`rd_est'", tstyle(size(medlarge))) ylabel(-0.4(.1)0.4, angle(0) labsize(large)) xlabel(-20(5)20, labsize(large)) legend(off) xscale(range(-20 20)) ytitle("Standard deviations", size(large)) title("Economic performance", size(large)))
graph export "$project_path/output/figures/Figure_4a.pdf", as(pdf) name("Graph") replace

** Figure 4(b)
use "$project_path/data/4_regdata/regdata", clear
rdrobust std_diff_m1_hdi runvar, all
local rdd_tau : di %8.3f e(tau_cl)
local rdd_lb : di %8.3f e(ci_l_rb)
local rdd_lb = subinstr("`rdd_lb'", " ", "", .)
local rdd_ub : di %8.3f e(ci_r_rb)
local rdd_ub = subinstr("`rdd_ub'", " ", "", .)
local rdd_pval : di %8.3f e(pv_rb)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local N = e(N)
local rd_est = "RD est.: `rdd_tau' [`rdd_lb', `rdd_ub']. p-value: `rdd_pval'. N = `N'"
rdplot std_diff_m1_hdi runvar if inrange(runvar, -20, 20), nbins(10 10)  p(1) graph_options(xtitle("Margin of victory of the challenger", size(large)) graphregion(color(white)) note("`rd_est'", tstyle(size(medlarge))) ylabel(-0.4(.1)0.4, angle(0) labsize(large)) xlabel(-20(5)20, labsize(large)) legend(off) xscale(range(-20 20)) ytitle("Standard deviations", size(large)) title("Human Development Index", size(large)))
graph export "$project_path/output/figures/Figure_4b.pdf", as(pdf) name("Graph") replace

** Figure 4(c)
use "$project_path/data/4_regdata/regdata", clear
rdrobust std_diff_m1_democracy_index runvar, all
local rdd_tau : di %8.3f e(tau_cl)
local rdd_lb : di %8.3f e(ci_l_rb)
local rdd_lb = subinstr("`rdd_lb'", " ", "", .)
local rdd_ub : di %8.3f e(ci_r_rb)
local rdd_ub = subinstr("`rdd_ub'", " ", "", .)
local rdd_pval : di %8.3f e(pv_rb)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local N = e(N)
local rd_est = "RD est.: `rdd_tau' [`rdd_lb', `rdd_ub']. p-value: `rdd_pval'. N = `N'"
rdplot std_diff_m1_democracy_index runvar if inrange(runvar, -20, 20), nbins(10 10)  p(1) graph_options(xtitle("Margin of victory of the challenger", size(large)) graphregion(color(white)) note("`rd_est'", tstyle(size(medlarge))) ylabel(-0.4(.1)0.4, angle(0) labsize(large)) xlabel(-20(5)20, labsize(large)) legend(off) xscale(range(-20 20)) ytitle("Standard deviations", size(large)) title("Democracy", size(large)))
graph export "$project_path/output/figures/Figure_4c.pdf", as(pdf) name("Graph") replace

** Figure 4(d)
use "$project_path/data/4_regdata/regdata", clear
rdrobust diff_m1_general_chix runvar, all
local rdd_tau : di %8.3f e(tau_cl)
local rdd_lb : di %8.3f e(ci_l_rb)
local rdd_lb = subinstr("`rdd_lb'", " ", "", .)
local rdd_ub : di %8.3f e(ci_r_rb)
local rdd_ub = subinstr("`rdd_ub'", " ", "", .)
local rdd_pval : di %8.3f e(pv_rb)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local N = e(N)
local rd_est = "RD est.: `rdd_tau' [`rdd_lb', `rdd_ub']. p-value: `rdd_pval'. N = `N'"
rdplot diff_m1_general_chix runvar if inrange(runvar, -20, 20), nbins(10 10)  p(1) graph_options(xtitle("Margin of victory of the challenger", size(large)) graphregion(color(white)) note("`rd_est'", tstyle(size(medlarge))) ylabel(-0.4(.1)0.4, angle(0) labsize(large)) xlabel(-20(5)20, labsize(large)) legend(off) xscale(range(-20 20)) ytitle("Standard deviations", size(large)) title("General index", size(large)))
graph export "$project_path/output/figures/Figure_4d.pdf", as(pdf) name("Graph") replace

